import java.util.Arrays;

public class Solution875 {
    public int minEatingSpeed(int[] piles, int h) {
        int l=1,r= Arrays.stream(piles).max().getAsInt();
        int ans=-1;
        while (l<=r){
            int mid=(l+r)/2;
            long sum=0;
            for (int pile : piles) {
                sum+=pile/mid+(pile%mid==0?0:1);
            }
            if (sum<=h){
                ans=mid;
                r=mid-1;
            }else {
                l=mid+1;
            }
        }
        return ans;
    }

    public static void main(String[] args) {
        System.out.println(new Solution875().minEatingSpeed(new int[]{3,6,7,11},8));
    }
}
